package com.erick.contacts.activity;

import com.erick.R;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.TextView;
import android.widget.Toast;

/**
 * @Title: ContactsDetail.java
 * @Package com.chen.activity
 * @company：科贸学院
 * @Description: 通讯录：个人中心
 * @author ChenBin
 * @date 2012-9-22 上午1:06:44
 * @version V1.0
 */
public class ContactsDetailActivity extends Activity {

	private TextView contactsName, contactsPhone, contactsEmail;
	private String name, email, phone;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.contacts_detail);

		getBundle(); // 取得Bundle数据
		initUI(); // 初始化控件UI
	}
	
	/*
	 * 初始化UI
	 */
	private void initUI() {
		contactsName = (TextView) findViewById(R.id.contactsName);
		contactsPhone = (TextView) findViewById(R.id.contacts_center_phone);
		contactsEmail = (TextView) findViewById(R.id.contacts_center_email);
		contactsName.setText(name);
		contactsPhone.setText("手机： " + phone);
		contactsEmail.setText("邮箱： " + email);
	}

	/*
	 * 获取Bundle数据
	 */
	private void getBundle() {
		Intent it = this.getIntent();
		name = it.getStringExtra("name");
		phone = it.getStringExtra("phone");
		email = it.getStringExtra("email");
	}

	public void onClickListener(View v) {
		int viewId = v.getId();
		switch (viewId) {
		case R.id.contacts_back:
			ContactsDetailActivity.this.finish();
			break;
		case R.id.linear1:
			// 拨打电话
			Uri phoneUri = Uri.parse("tel:" + phone);
			Intent phoneIntent = new Intent(Intent.ACTION_CALL, phoneUri);
			ContactsDetailActivity.this.startActivity(phoneIntent);
			break;
		case R.id.linear2:
			// 发送短信
			Uri msgUri = Uri.parse("smsto:" + phone);
			Intent msgIntent = new Intent(Intent.ACTION_SENDTO, msgUri);
			ContactsDetailActivity.this.startActivity(msgIntent);
			break;
		case R.id.linear3:
			Toast.makeText(ContactsDetailActivity.this, "写小纸条", 0).show();
			break;
		case R.id.linear4:
			Toast.makeText(ContactsDetailActivity.this, "纸条记录", 0).show();
			break;
		default:
			break;
		}
	}
}
